<template>
	<div id="shohuodindan">
		<h1 class="demo-form-inline" style="inline-heigth: 100px; text-align: center; margin: auto;">待收货订单</h1>
		
		<!-- 表格 -->
				<el-table :data="shohuodindanALL" style="width: 100%">
					<el-table-column prop="id" label="订单ID" width="180">
					</el-table-column>
				  <el-table-column prop="orderId" label="订单编号">
				  </el-table-column>
				  <el-table-column prop="totalAmount" label="订单总金额">
				  </el-table-column>
				  <el-table-column prop="orderStatus" label="订单状态">
				  </el-table-column>
				  <el-table-column prop="conveyTag" label="配送标志">
					  <template slot-scope="scope">
					  	<span v-if="scope.row.conveyTag=='P001-3'">待收货</span>
					  </template>
				  </el-table-column>
				  <el-table-column prop="paymentMethod" label="支付方式">
					  <template slot-scope="scope">
						<span v-if="scope.row.paymentMethod=='P002-1'">余额支付</span>
						<span v-if="scope.row.paymentMethod=='P002-2'">微信支付</span>
						<span v-if="scope.row.paymentMethod=='P003'">现金支付</span>
					  </template>
				  </el-table-column>
				  <el-table-column prop="payStatus" label="支付状态">
					  <template slot-scope="scope">
						<span v-if="scope.row.payStatus=='K002-1'">等待支付</span>
						<span v-if="scope.row.payStatus=='K002-2'">支付失败</span>
						<span v-if="scope.row.payStatus=='K002-3'">支付成功</span>
					  </template>
				  </el-table-column>
				 <!--操作列-->
				  <el-table-column label="操作">
				  <template slot-scope="scope">
					<el-button size="small"
					round 
					type="primary"
					@click="viewdetails(scope.$index,scope.row)">查看详情</el-button>
					<el-button v-if="scope.row.conveyTag=='P001-3'"
					size="small"
					round 
					type="primary"
					@click="receiving(scope.$index,scope.row)">收货</el-button>
				  </template>
				</el-table-column>
				 </el-table>
		
				<!---分页组件-->
				 <el-pagination  style="inline-heigth: 100px; text-align: center; margin: auto;"
				 @size-change="handleSizeChange"
					  @current-change="handleCurrentChange"
					  :current-page="pageNo"
					  :page-sizes="pageSizeList"
					  :page-size="pageSize"
					  layout="total, sizes, prev, pager, next, jumper"
					  :total="total">
				 </el-pagination>
				 
				 
				 <!-- 添加表看订单明细 -->
				  <el-dialog title="查看详情订单" :visible.sync="makeFormVisible" >
				  	<el-table :data="receivingorderOne" style="width: 100%">
				  	<el-table-column prop="productName" label="商品名称">
				  	</el-table-column>
				  	<el-table-column prop="amount" label="数量">
				  	</el-table-column>
				  	<el-table-column prop="price" label="单价">
				  	</el-table-column>
				  	<el-table-column prop="subtotal" label="小计">
				  </el-table-column>
				  </el-table>
				      </el-dialog>
				  					 
			</div>
		</template>
		
<script>
			export default {
			      data() {
			        return {
						shohuodindanALL: [],
						//回显对象
						receivingorderOne:[],
						//当前页号
						pageNo: 1,
						//当前页大小
						pageSize: 2,
						//总记录数
						total: 0,
						//页大小列表
						pageSizeList: [2, 5, 10, 20],
						//添加对话框的显示
						makeFormVisible: false,
						}
					},
					created() {
						// this.handleSizeChange(),
						// this.handleCurrentChange(),
						this.shohuodindan()
					},
			         methods:{
						 // 页大小改变
						   handleSizeChange(val) {
						 	  this.pageSize = val
						 	  this.shohuodindan()
							  
						   },
						   
						 //页号改变
						 handleCurrentChange(val) {
						 	this.pageNo = val
						 	// 重新查询
						 	this.shohuodindan()
						 },
						 
						 //分页查询采购订单表
						 async shohuodindan() { 
						 	// 用es6的解构函数
               let cid=	sessionStorage.getItem("token")
							console.log(1)
						 	const {data: res} = await this.$http.post
						 	(`/buy/order/shohuodindan/${this.pageSize}/${this.pageNo}/${cid}`)
						 	this.shohuodindanALL = res.list
						 	this.total = res.total
						 },
						 
						  //点击收货
							 async receiving(index,row) {
								// 用es6的解构函数
								const {data: res} = await this.$http.post(`/buy/order/receiving/${row.id}`)
								console.log(res)
							 //	this.receiving()
							 if(res!='error'){
								 this.$message({
										   showClose: true,
										   message: '收货成功',
										   type: 'success'
										 });
										 this.shohuodindan()
							 }else{
								 this.$message({
										   showClose: true,
										   message: '收货失败',
										   type: 'success'
										 });
							 }
										//this.$route.path('/shohuodindan')
							 },
						 
						  //点击审核
						 async passtheaudit(index,row) {
							// 用es6的解构函数
							const {data: res} = await this.$http.post(`/buy/orderDetailsC/passtheaudit/${row.id}`)
							console.log(res)
						 //	this.receiving()
						 if(res!='error'){
							 this.$message({
									   showClose: true,
									   message: '审核成功',
									   type: 'success'
									 });
									 this.shohuodindan()
						 }else{
							 this.$message({
									   showClose: true,
									   message: '审核失败',
									   type: 'success'
									 });
						 }
									//this.$route.path('/shohuodindan')
						 },
						 
						 //点击查看详情
						 async viewdetails(index,row) {
						 	// 用es6的解构函数
						 //显示表
						 this.makeFormVisible = true
						 const {data: res} = await this.$http.post(`/buy/orderDetails/orderdetaid/${row.id}`)
						 console.log(123456,res)
						     this.receivingorderOne=res
						},
						 //点击收货
						 async receiving(index,row) {
						 	// 用es6的解构函数
						 	const {data: res} = await this.$http.post(`/buy/order/receiving/${row.id}`)
							console.log(res)
						 //	this.receiving()
						 if(res!='error'){
							 this.$message({
							           showClose: true,
							           message: '收货成功',
							           type: 'success'
							         });
									 this.shohuodindan()
						 }else{
							 this.$message({
							           showClose: true,
							           message: '收货失败',
							           type: 'success'
							         });
						 }
									//this.$route.path('/shohuodindan')
						 },
					 }
			        }
			      
			    
			
		</script>
		
<style>
</style>